package com.blockchain.front.servlets.financial;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.blockchain.framework.service.ServiceSession;
import com.blockchain.front.service.financial.QbManage;
import com.blockchain.util.StringHelper;
import com.blockchain.util.parser.IntegerParser;

public class Tbzc extends AbstractFinancialServlet {
	private static final long serialVersionUID = 1L;

	@Override
	protected void processGet(HttpServletRequest request, HttpServletResponse response, ServiceSession serviceSession)
			throws Throwable {
		processPost(request, response, serviceSession);
	}

	@Override
	protected void processPost(HttpServletRequest request, HttpServletResponse response, ServiceSession serviceSession)
			throws Throwable {
		int bid = IntegerParser.parse(request.getParameter("bid"));
		String dz = request.getParameter("dz");
		if (bid > 0 && !StringHelper.isEmpty(dz)) {
			QbManage qbmanage = serviceSession.getService(QbManage.class);
			String bjc = qbmanage.bjc(bid);// 获取币简称
			if ("TCC".equals(bjc)) {
				bjc = "6CAB220FC47B66486AC27F3A91A0BA5A6003A860";
			}
			qbmanage.synchronization(bid, dz, bjc);
		}
		String url = getController().getViewURI(request, XlbZr.class) + "?bid=" + bid;
		sendRedirect(request, response, url);
	}
}
